﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            int i, j;
            int maxValue = 1000;
            bool flag;
            String str = "";
            for (i = 2; i <= maxValue; i++)
            {
                flag = true;
                for (j = 2; j < i; j++)
                {
                    if (i % j == 0)
                    {
                        flag = false;
                        break;
                    }
                }
                if (flag)
                {
                    str = Convert.ToString(str + " " + i);
                }
            }
            richTextBox1.Text = str;
        }
    }
}
